package com.chixing.ih.module.admin.service.Impl;

import com.chixing.ih.module.admin.mapper.AdminOrderMapper;
import com.chixing.ih.module.admin.pojo.dto.OrderUserTaskDTO;
import com.chixing.ih.module.admin.service.IAdminOrderService;
import com.github.pagehelper.PageHelper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
@Transactional
public class AdminOrderServiceImpl implements IAdminOrderService {

    @Autowired
    private AdminOrderMapper adminOrderMapper;


    @Override
    public List<OrderUserTaskDTO> getSettlementingOrder(Integer pageNum, Integer pageSize, String keyword) {
        PageHelper.startPage(pageNum, pageSize);
        return adminOrderMapper.getSettlementingOrder(keyword);
    }

    @Override
    public List<OrderUserTaskDTO> getRefusingOrder(Integer pageNum, Integer pageSize, String keyword) {
        PageHelper.startPage(pageNum, pageSize);
        return adminOrderMapper.getRefusingOrder(keyword);
    }

    @Override
    public List<OrderUserTaskDTO> getCompletedOrder(Integer pageNum, Integer pageSize) {
        PageHelper.startPage(pageNum, pageSize);
        return adminOrderMapper.getCompletedOrder();
    }

    @Override
    public List<OrderUserTaskDTO> getRefundedOrder(Integer pageNum, Integer pageSize) {
        PageHelper.startPage(pageNum, pageSize);
        return adminOrderMapper.getRefundedOrder();
    }

    @Override
    public boolean agreeToSettlement(Integer orderId, Integer taskId) {
        boolean b = adminOrderMapper.agreeToSettlement(orderId);
        if (b)
            return adminOrderMapper.setIsDeleted(taskId);
        return false;
    }

    @Override
    public boolean agreeToRefund(Integer orderId, Integer taskId) {
        boolean b = adminOrderMapper.agreeToRefund(orderId);
        if (b)
            return adminOrderMapper.setIsDeleted(taskId);
        return false;
    }

    @Override
    public List<OrderUserTaskDTO> getAllOrder(Integer pageNum, Integer pageSize,String keyword) {
        PageHelper.startPage(pageNum, pageSize);
        return adminOrderMapper.getAllOrder(keyword);
    }


}
